﻿using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ViewLED.UI
{
    /// <summary>
    /// ImgEle.xaml 的交互逻辑
    /// </summary>
    public partial class ImgEle : UserControl
    {
        private BitmapImage img;
        private int stretchType;

        public ImgEle()
        {
            InitializeComponent();
        }

        public BitmapImage Img
        {
            get { return img; }
            set
            {
                img = value;
                imgBack.Source = img;
            }
        }

        public int StretchType
        {
            get { return stretchType; }
            set 
            { 
                stretchType = value;
                setStretchType(stretchType);
            }
        }

        private void setStretchType(int index)
        {
            switch(index)
            {
                case 0:
                    imgBack.Stretch = Stretch.None;
                    break;
                case 1:
                    imgBack.Stretch = Stretch.Fill;
                    break;
                case 2:
                    imgBack.Stretch = Stretch.Uniform;
                    break;
                case 3:
                    imgBack.Stretch = Stretch.UniformToFill;
                    break;
            }
        }
    }
}
